﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
using FTchina.Library;
using FTchina;
using PWMIS.DataMap.Entity;
using FTchina.Models;
namespace FTchina.Logic
{/// <summary>
    ///IPtable 的摘要说明
    /// </summary>
    public class IPtableLogic
    {
        public IPtableLogic()
        {
            //
            //TODO: 在此处添加构造函数逻辑
            //
        }
        #region IP操作，获取，转换
        /// <summary>
        /// 检查用户ip是否禁止
        /// </summary>
        /// <returns>true禁止；flase通过</returns>
        public static void CheckUserIP(Page ValidatePage)
        {


            Int64 user = RequestHelper.GetIPNum(RequestHelper.GetUserIp());

            Iptable ipt = new Iptable();
            OQL q = new OQL(ipt);
            q.Select().Where().OrderBy(ipt.Id, "desc");
            List<Iptable> list = EntityQuery<Iptable>.QueryList(q).ToList();
            foreach (Iptable _ipt in list)
            {
                if (user >= RequestHelper.GetIPNum(_ipt.Bip) && user <= RequestHelper.GetIPNum(_ipt.Eip))
                {//ip在数据库的ip段范围内

                    ValidatePage.Response.Write(MasterHelper.LoginIP + "无权访问此页");

                    break;
                }

            }

            


        }




        #endregion

    }
}